package cz.czu.pef.DataModelling.servlet;

import java.io.IOException;
import java.io.PrintWriter;

//import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import cz.czu.pef.DataModelling.Person;
import cz.czu.pef.DataModelling.ejb.api.AbstractWrapperService;

@Controller
public class EjbInvokerServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {

   /**
	 * 
	 */
	private static final long serialVersionUID = 556823566284490215L;

	@Autowired private AbstractWrapperService<Person> personServiceEJB;

    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public EjbInvokerServlet() {
		super();
	}

	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println(personServiceEJB.findAll());
	}

	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}   	  	    
}